// components/search-bar/index.js
Component({
	/**
	 * 组件的属性列表
	 */
	properties: {
		placeholder: {
			type: String,
			value: ''
		}
	},

	/**
	 * 组件的初始数据
	 */
	data: {
		value: ''
	},

	/**
	 * 组件的方法列表
	 */
	methods: {
		onChange: function(e) {
			//debugger;
			//console.log(e);
			this.setData({
				value: e.detail
			});

		},
		onSearch: function(e) {
			//console.log(e);
			// console.log("data "+JSON.stringify(this.data));
			// console.log(" placeholder "+JSON.stringify(this.properties));
			var searchKey = this.data.value;
			var event = e;

			/*
			 *这里的handleSearch必须和页面的<searchBar bind:handleSearch="..."></searchBar>的绑定的函数名一致
			 *不必与·handleSearch22·一致即可
			 */
			this.triggerEvent('handleSearch', {
				placeholder: this.properties.placeholder,
				searchKey,
				event
			}, {})

		}
	}
})
